﻿using DX_Recognize.Common;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DX_Recognize
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            if (CADCommonForm.hasDataForm == false)
            {
                CADCommonForm.hasDataForm = true;
                CADCommonForm.DataFrom = new DataForm();
            }
            openChildForm(CADCommonForm.DataFrom);
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            // 启动位置
            this.StartPosition = FormStartPosition.Manual;
            this.Location = new Point(42, 175);
        }

        //关闭所有嵌入窗体并显示新窗体
        private void openChildForm(Form childForm)
        {
            if (CADCommonForm.activeForm != null) CADCommonForm.activeForm.Hide();
            CADCommonForm.activeForm = childForm;
            childForm.TopLevel = false; //解除顶层窗体
            childForm.FormBorderStyle = FormBorderStyle.None; //边框为无
            childForm.Dock = DockStyle.Fill; //填充
           /* panelChildForm.Controls.Add(childForm); //父控件为panelChildForm
            panelChildForm.Tag = childForm;*/
            childForm.BringToFront();
            childForm.Show();
        }
        
        private void btnMouldData_Click(object sender, EventArgs e)
        {
            if (CADCommonForm.hasDataForm == false)
            {
                CADCommonForm.hasDataForm = true;
                CADCommonForm.DataFrom = new DataForm();
            }
            openChildForm(CADCommonForm.DataFrom);
        }

        private void btnExit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.Hide();//窗口隐藏
            e.Cancel = true;//取消关闭
        }
    

    }
}
